/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-11-30
 * Time: 22:54
 */
public class TestH20 {
    public String longestCommonPrefix(String[] strs) {
        int n = strs.length;
        for(int i = 0; i < strs[0].length(); i++) {
            for(int j = 1; j < n; j++) {
                if(i == strs[j].length() || strs[0].charAt(i) != strs[j].charAt(i)) {
                    return strs[0].substring(0,i);
                }
            }
        }

        return strs[0];
    }
}
